package com.ruoyi.gams.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gams.domain.GamsUserQueue;
import com.ruoyi.gams.service.IGamsUserQueueService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 排队Controller
 *
 * @author ruoyi
 * @date 2021-09-03
 */
@RestController
@RequestMapping("/gams/user_queue")
public class GamsUserQueueController extends BaseController
{
    @Autowired
    private IGamsUserQueueService gamsUserQueueService;

    /**
     * 查询排队列表
     */
    @PreAuthorize("@ss.hasPermi('gams:user_queue:list')")
    @GetMapping("/list")
    public TableDataInfo list(GamsUserQueue gamsUserQueue)
    {
        startPage();
        List<GamsUserQueue> list = gamsUserQueueService.selectGamsUserQueueList(gamsUserQueue);
        return getDataTable(list);
    }

    /**
     * 导出排队列表
     */
    @PreAuthorize("@ss.hasPermi('gams:user_queue:export')")
    @Log(title = "排队", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GamsUserQueue gamsUserQueue)
    {
        List<GamsUserQueue> list = gamsUserQueueService.selectGamsUserQueueList(gamsUserQueue);
        ExcelUtil<GamsUserQueue> util = new ExcelUtil<GamsUserQueue>(GamsUserQueue.class);
        return util.exportExcel(list, "排队数据");
    }

    /**
     * 获取排队详细信息
     */
    @PreAuthorize("@ss.hasPermi('gams:user_queue:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(gamsUserQueueService.selectGamsUserQueueById(id));
    }

    /**
     * 新增排队
     */
    @PreAuthorize("@ss.hasPermi('gams:user_queue:add')")
    @Log(title = "排队", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GamsUserQueue gamsUserQueue)
    {
        return toAjax(gamsUserQueueService.insertGamsUserQueue(gamsUserQueue));
    }

    /**
     * 修改排队
     */
    @PreAuthorize("@ss.hasPermi('gams:user_queue:edit')")
    @Log(title = "排队", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GamsUserQueue gamsUserQueue)
    {
        return toAjax(gamsUserQueueService.updateGamsUserQueue(gamsUserQueue));
    }

    /**
     * 删除排队
     */
    @PreAuthorize("@ss.hasPermi('gams:user_queue:remove')")
    @Log(title = "排队", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(gamsUserQueueService.deleteGamsUserQueueByIds(ids));
    }
}
